const express = require("express");
const app = express();
const port = 9999;

app.use(express.json());

// Mock API endpoint

app.post("/api/getUser", (req, res) => {
  console.log(req.body);
  if (req.body.username === "admin" && req.body.password === "123456") {
    res.json({
      code: "200",
      message: "登录成功",
      data: {
        name: "Heisenberg",
      },
    });
  } else {
    res.json({
      code: "201",
      message: "Hello, this is mock data!",
      data: { username: "admin", password: "123456" },
    });
  }
});
app.get("/api/data", (req, res) => {
  res.json({
    message: "Hello, this is mock data!",
    data: [1, 2, 3, 4, 5],
  });
});

// Catch all route to handle other requests
app.get("*", (req, res) => {
  res.status(404).send("Not Found");
});

app.listen(port, () => {
  console.log(`原神启动 http://localhost:${port}`);
});
